/**
 * 							Timer Defination
 * @brief	Timer Definaton
 * @author	chy.
 * @note
 * @comment	this file defines macros and functions used by common time module!
 */

#ifndef	_K_DRIV_TIMER_S3C2440_C_
#define	_K_DRIV_TIMER_S3C2440_C_

/**
 * @BRIEF	:	Initialize Timer
 * @PARAM	:	void
 * @RETURN	:	void
 * @NOTE	:	The hard timer is different in different platform.But must make sure this will hold one hard timer!
 */
void k_driv_s3c2440_timer_init(void)
{
	TCFG0 = 0;
	TCFG1 = 0;
	TCON  = 0;
}


/**
 * @BRIEF	:	Start Timer
 * @PARAM	:	id	timer id.
 * @PARAM	:	count_val	count value for count buffer
 * @PARAM	:	comp_val	compare value for compare buffer
 * @RETURN	:	void
 * @NOTE	:	The hard timer is different in different platform.But must make sure this will hold one hard timer!
 * 			:	The timer will start in this function.
 */
void k_driv_s3c2440_timer_start(KD_TimerID id, unsigned short count_val, unsigned short comp_val)
{
	switch(id)
	{
		case KD_TIMER_0:
		{
			TCNTB0	= count_val;
			TCMPB0	= comp_val;
			TCON &= 0xfffffff8;	// close auto mode.
			TCON |= 0x3;		// as we assume use timer 0 for the system schedule
		}
		break;
		case KD_TIMER_1:
		{
			TCNTB1	= count_val;
			TCMPB1	= comp_val;
		}
		break;
		case KD_TIMER_2:
		{
			TCNTB2	= count_val;
			TCMPB2	= comp_val;
		}
		break;
		case KD_TIMER_3:
		{
			TCNTB3	= count_val;
			TCMPB3	= comp_val;
		}
		break;
		case KD_TIMER_4:
		{
			TCNTB4	= count_val;
			// timer 4 has no compare registers
		}
		break;
	}
}

/**
 * @BRIEF	:	Read Timer Count Value
 * @PARAM	:	id		timer id
 * @RETURN	:	count value
 * @NOTE	:	The hard timer is different in different platform.But must make sure this will hold one hard timer!
 * 			:	The timer will start in this function.
 */
unsigned short	k_driv_s3c2440_timer_read_count(KD_TimerID id)
{

}

#endif	/* _K_DRIV_TIMER_S3C2440_C_ */